<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        div{
            width: 200px;
            height: 200px;
            background: red;
        }
    </style>
</head>
<body>
<input type="text"onkeydown="keydownfn()" onkeyup="keyupfn()"
onkeypress="pressfn()">
<div onmouseover="overfn()" onmouseout="outfn()"
onmousedown="downfn()" onmouseup="upfn()" onmousemove="movefn()"></div>
<script>
    /*按下非功能键时触发*/
    function pressfn() {
        console.log('按下了内容')
    }
    /*按下任何键触发*/
    function keydownfn() {
        console.log('键盘按下:按键编码='+event.keyCode)
    }
    function keyupfn() {
        console.log('键盘抬起:字符='+String.fromCharCode(event.keyCode))
    }

    function overfn() {
        console.log('鼠标移入')
    }
    function outfn() {
        console.log('鼠标移出')
    }
    function downfn() {
        console.log('鼠标按下')
    }
    function upfn() {
        console.log('鼠标抬起')
    }
    function movefn() {
        console.log('鼠标移动')
    }
</script>
</body>
</html>